<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    	<title>统战成员学习平台</title>
	    <link rel="stylesheet" type="text/css" href="../css/base.css" />
	    <link rel="stylesheet" type="text/css" href="../css/style.css" />
		<style>
			html, body{
				height: 100%;
				overflow: hidden;
			}
		</style>
	</head>
	<body>
		<div id='app' style="display:none" v-show="true" class="main_bg">
			<header>
				<div>
					<span tapmode onclick="closeWin()" class="left"><i class="icon_back_white"></i></span>
					<p style="color:#fff">用户登录</p>
				</div>
			</header>
			<div class="login_container" :class="{'hidden': hidden}">
				<div class="logo_c">
					<img class="logo" :class="{'hidden': hidden}" src="../image/logo.png">
					<p>统战学习平台</p>
				</div>
				<div class="login_form">
                    <div class="item ui_border_b">
                        <img src="../image/username.png"><input @focus="inputFocus()" @blur="inputBlur()" v-model="usrAccount" type="text" placeholder="账号">
                    </div>
                    <div class="item">
                        <img src="../image/password.png"><input @focus="inputFocus()" @blur="inputBlur()" v-model="usrPassword" type="password" placeholder="密码">
						<span @click="openWin('forgetPass')">忘记密码？</span>
                    </div>
                </div>
				<div tapmode="tap" @click="login()" class="login_btn">登录</div>
				<p class="agreement">
					<span class="checkbox"><label for="checkbox1"></label><input v-model="checked" type="checkbox" id="checkbox1"><span></span></span>
					我已阅读并同意《<span class="a" @click="openWin('agreement_win')">服务协议</span>》
				</p>
			</div>
		</div>
		<script type="text/javascript" src="../script/api.js"></script>
		<script type="text/javascript" src="../script/vue.min.js"></script>
		<script type="text/javascript" src="../script/common.js"></script>
		<script type="text/javascript" src="../script/layer_mobile/layer.js"></script>
		<script type="text/javascript">
		    new Vue({
		     	el: '#app',
		     	data: {
					hidden: false,
		            usrAccount: '',
		            usrPassword: '',
					checked: false,
					height: '100%'
		     	},
		     	mounted: function() {
		        	var $this = this;
		        	apiready = function() {
						var header = $api.dom('header');
						$api.fixStatusBar(header);
						sbsm.opened();
                	}
		    	},
		    	methods: {
					login: function() {
						var $this = this;
						if(!$this.usrAccount.length) return msgUtil.toast({msg: '请输入账号'});
						if(!$this.usrPassword.length) return msgUtil.toast({msg: '请输入密码'});
						if(!$this.checked) return msgUtil.message('请阅读并同意服务协议');
						var loginLoading = msgUtil.loading();
						post('/client/user/applogin', {
							usrAccount: $this.usrAccount,
							usrPassword: MD5($this.usrPassword),
							requestType: 'partyconstruction_app'
						}, function(ret) {
							msgUtil.close(loginLoading);
							if(ret.isSuccess) {
									$api.setStorage(_.USERINFO, ret.data);
								var wifionly = $api.getStorage(_.WIFIONLY);
								if(!$api.getStorage(_.WIFIONLY)){
									//设置默认值
									$api.setStorage(_.WIFIONLY, true);
								}

								api.sendEvent({name: 'user_login_logout_event'});
								api.sendEvent({name: EVENT.OPEN_INIT_FRAMES});
								closeWin();
							} else {
								msgUtil.message(ret.message);
							}
						})
					},
					inputFocus: function() {
						var $this = this;
						$this.hidden = true;
					},
					inputBlur: function() {
						var $this = this;
						$this.hidden = false;
					}
		    	}
		    });
		</script>
	</body>
</html>
